package com.xiaoma.spring.factorybean;

import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * @author xiaomacdut
 * @date 2020年2月28日 下午12:08:40
 */
public class Main{
    
    public static void main(String [] args) throws Exception{
        ApplicationContext beans = new AnnotationConfigApplicationContext("com.xiaoma.pattern.spring.factorybean");
        /*        Car protoTypeCar1 = (Car) beans.getBean("protoTypeCarFactoryBean");
        Car protoTypeCar2 = (Car) beans.getBean("protoTypeCarFactoryBean");
        System.out.println("" + (protoTypeCar1 == protoTypeCar2) + " " + protoTypeCar1 + " " + protoTypeCar2);
        Car singletonCar1 = (Car) beans.getBean("singletonCarFactoryBean");
        Car singletonCar2 = (Car) beans.getBean("singletonCarFactoryBean");
        System.out.println("" + (singletonCar1 == singletonCar2) + " " + singletonCar1 + " " + singletonCar2);*/
        
        SingletonCarFactoryBean factoryBean1 = (SingletonCarFactoryBean) beans.getBean("&singletonCarFactoryBean");
        SingletonCarFactoryBean factoryBean2 = (SingletonCarFactoryBean) beans.getBean(SingletonCarFactoryBean.class);
        System.out.println(factoryBean1.getObject().getColour());
        // System.out.println("" + (factoryBean1 == factoryBean2) + " " + factoryBean1 + " " +
        // factoryBean2);
        
    }
}
